﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace _2._1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        ArrayList a = new ArrayList();
        int length = 0;


       
        private void btn1_Click(object sender, EventArgs e)
        {
            try
            {
                int ele = int.Parse(input1.Text);
                a.Add(ele);
                //tb1.Text = a[length].ToString();
                output1.Text = output1.Text+a[length] + " ";
                length++;
                input1.Text = "";
                return;
            }
            catch (Exception)
            {
                input1.Text = "请输入整形";
                return;
            }
        }

        

        private void btn2_Click(object sender, EventArgs e)
        {
            if (length <= 0) { return; }
            a.Clear();
            output1.Text = "";
            length = 0;
        }

        private void btn3_Click(object sender, EventArgs e)
        {
            if (length <= 0) { return; }
            int average=0;
            int max=(int)a[0];
            int min = (int)a[0];
            foreach(int i in a)
            {
                if (max < i) { max = i; }
                if (min > i) { min = i; }
                average += i;
            }
            tb1.Text = max.ToString();
            tb2.Text = min.ToString();
            tb4.Text = average.ToString();
            tb3.Text = ((float)average/ length).ToString();

        }
    }
}
